﻿using System;
using System.Collections.Generic;
using System.Net;
using System.ServiceModel.DomainServices.Client;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using AR.Entities;
using AR.Helpers;
using AR.Web.Services;

namespace AR.Model
{
    public class TesttechniqueData : List<THEME>
    {
        public TesttechniqueData()
      {
          EntretienTechniqueContext entretiencontext = new EntretienTechniqueContext();
          LoadOperation loadOp = entretiencontext.Load<THEME>(entretiencontext.GetTHEMEQuery(), LoadBehavior.RefreshCurrent, (s) =>
          {

              if (s.HasError)
              {
                  s.MarkErrorAsHandled();
                  Tools.AfficheNotificationFlash(s.Error.Message);
              }
              else
              {
                  entretiencontext.THEMEs.EntityAdded += OnEntityAdded;
                 

                  // CreateControls(entretiencontext.THEMEs);


              }
              //busy indicator
          }, null);
      }
        
        private void OnEntityAdded(object sender,
                              EntityCollectionChangedEventArgs<THEME> entityCollectionChangedEventArgs)
        {
            
            this.Add(entityCollectionChangedEventArgs.Entity);
        }

    }
}
